package com.ruoyi.boss.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.boss.domain.TCancel;
import com.ruoyi.boss.service.ITCancelService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 取消订单Controller
 * 
 * @author ruoyi
 * @date 2025-08-17
 */
@RestController
@RequestMapping("/cancel")
public class TCancelController extends BaseController
{
    @Autowired
    private ITCancelService tCancelService;

    /**
     * 查询取消订单列表
     */
    @RequiresPermissions("boss:cancel:list")
    @GetMapping("/list")
    public TableDataInfo list(TCancel tCancel)
    {
        startPage();
        List<TCancel> list = tCancelService.selectTCancelList(tCancel);
        return getDataTable(list);
    }

    /**
     * 导出取消订单列表
     */
    @RequiresPermissions("boss:cancel:export")
    @Log(title = "取消订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TCancel tCancel)
    {
        List<TCancel> list = tCancelService.selectTCancelList(tCancel);
        ExcelUtil<TCancel> util = new ExcelUtil<TCancel>(TCancel.class);
        util.exportExcel(response, list, "取消订单数据");
    }

    /**
     * 获取取消订单详细信息
     */
    @RequiresPermissions("boss:cancel:query")
    @GetMapping(value = "/{cancelId}")
    public AjaxResult getInfo(@PathVariable("cancelId") Long cancelId)
    {
        return success(tCancelService.selectTCancelByCancelId(cancelId));
    }

    /**
     * 新增取消订单
     */
    @RequiresPermissions("boss:cancel:add")
    @Log(title = "取消订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TCancel tCancel)
    {
        return toAjax(tCancelService.insertTCancel(tCancel));
    }

    /**
     * 修改取消订单
     */
    @RequiresPermissions("boss:cancel:edit")
    @Log(title = "取消订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TCancel tCancel)
    {
        return toAjax(tCancelService.updateTCancel(tCancel));
    }

    /**
     * 删除取消订单
     */
    @RequiresPermissions("boss:cancel:remove")
    @Log(title = "取消订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cancelIds}")
    public AjaxResult remove(@PathVariable Long[] cancelIds)
    {
        return toAjax(tCancelService.deleteTCancelByCancelIds(cancelIds));
    }
}
